﻿using System;
using Bricks.ExceptionHandling;
using Microsoft.Practices.EnterpriseLibrary.ExceptionHandling;

namespace Bricks.EnterpriseLibrary.ExceptionHandling
{

    /// <summary>
    /// 
    /// </summary>
    public class ExceptionManagerFacade : ExceptionHandlerFacadeBase<ExceptionManager>, IExceptionManagerFacade
    {

        /// <summary>
        /// 
        /// </summary>
        /// <param name="exceptionManager"></param>
        public ExceptionManagerFacade(ExceptionManager exceptionManager) :
            base(() => exceptionManager)
        {
            if (exceptionManager == null)
            {
                throw new ArgumentNullException("exceptionManager");
            }
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="exceptionToHandle"></param>
        /// <param name="key"></param>
        public override bool Handle(Exception exceptionToHandle, string key)
        {
            return Execute<bool>(exceptionManager => exceptionManager.HandleException(exceptionToHandle, key));
        }
    }
}
